﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MethodWorx.Core.Random
{
    public class RandomCharacterGenerator
    {
        public RandomNumberGenerator RandomNumberGenerator
        {
            get;
            private set;
        }

        public RandomCharacterGenerator() 
            : this(new RandomNumberGenerator())
        {
        }

        public RandomCharacterGenerator(RandomNumberGenerator randomNumberGenerator)
        {
            this.RandomNumberGenerator = randomNumberGenerator;
        }

        public virtual char Next(char[] chars)
        {
            return chars[this.RandomNumberGenerator.Next(0, chars.Length - 1)];
        }

        public virtual char NextNotIn(char[] chars)
        {
            while (true)
            {
                char c = (char)this.RandomNumberGenerator.Next(1, 255);
                if (!chars.Contains(c))
                    return c;
            }

        }
    }
}
